﻿using System;
using Common.Entities;
using Common.Enums;
using DataAccess.DAO;

namespace DataAccess.Converters
{
    public class SocialNetworkConverter : ISocialNetworkConverter
    {
        public SocialNetwork ConvertToEntity(SocialNetworkDAO entityDao)
        {
            var name = (SocialNetworkName) Enum.Parse(typeof (SocialNetworkName), entityDao.SocialNetworkName, true);
            return new SocialNetwork(name, entityDao.SocialNetworkAddress);
        }

        public SocialNetworkDAO ConvertToEntityDAO(SocialNetwork entity)
        {
            return new SocialNetworkDAO()
                       {
                           SocialNetworkName = entity.SocialNetworkName.ToString(),
                           SocialNetworkAddress = entity.SocialNetworkAddress
                       };
        }
    }
}
